export default {

    methods : {

        df_short(row, column){
            let date = moment(row[column.property]).format('YYYY-MM-DD')
            return date
        },
        df_long(row, column){

            let date = moment(row[column.property]).format('YYYY-MM-DD HH:mm:ss')
            return date
        },
        in_array(value,arr){
            
            let tmp = (arr || []).filter(item=>{return item==value;});
            return (tmp!= null && tmp.length > 0) ? true : false;
        },
        //获取缩略图列表
        getThumbnail(value){
            let urls = value.split(",");
            let index = 1;
            let fileList = [];
            urls.forEach(url => {
                let pos = url.lastIndexOf(".");
                let ext = "",
                preUrl = "";
                if (pos > 0) {
                    ext = url.substring(pos + 1);
                    preUrl = url.substring(0, pos);
                } else {
                    preUrl = url;
                }
      
                fileList.push({name: "文件" + index,url: HOST + preUrl + "_thumbnail.jpg",sourceUrl: url});
                index++;
            });
            return fileList;
        },
        eq_object(obj,dist) {
            if(!obj || !dist) return false;
            var result = true;
            for (let k in dist) {
                if (dist[k] != obj[k]) {
                    result = false;
                    break;
                }
            }
            return result;
        },
        eq_array(array1,array2){
            if(Array.isArray(array1) && Array.isArray(array2)){
                array1 = array1.sort().join('');
                array2 = array2.sort().join('');
                return array1 === array2;
            }
            return false;
            
        }
    }
}